package com.ctyon.common.util;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.graphics.Color;
import android.view.View;
import android.widget.TextView;

import com.ctyon.common.R;
import com.ctyon.common.snackbar.TSnackbar;


/**
 * Created by Lee on 2017/4/11.
 */

@SuppressLint("NewApi")
public class TSnackbarUtil {

    public static void TSBSuccess(Activity activity, String msg){
        TSnackbar tSnackbar = TSnackbar.make(activity.getWindow().getDecorView(),msg,TSnackbar.LENGTH_SHORT);
        tSnackbar.setActionTextColor(Color.BLACK);
        View tSnackbarView = tSnackbar.getView();
        tSnackbarView.setBackgroundColor(Color.parseColor("#26BFA1"));
        TextView textView = (TextView) tSnackbarView.findViewById(R.id.snackbar_text);
        textView.setTextColor(Color.WHITE);
        tSnackbar.show();
    }

    public static void TSBSuccessLong(Activity activity, String msg){
        TSnackbar tSnackbar = TSnackbar.make(activity.getWindow().getDecorView(),msg,TSnackbar.LENGTH_LONG);
        tSnackbar.setActionTextColor(Color.BLACK);
        View tSnackbarView = tSnackbar.getView();
        tSnackbarView.setBackgroundColor(Color.parseColor("#26BFA1"));
        TextView textView = (TextView) tSnackbarView.findViewById(R.id.snackbar_text);
        textView.setTextColor(Color.WHITE);
        tSnackbar.show();
    }

    public static void TSBError(Activity activity, String msg){
        TSnackbar tSnackbar = TSnackbar.make(activity.getWindow().getDecorView(),msg,TSnackbar.LENGTH_SHORT);
        tSnackbar.setActionTextColor(Color.BLACK);
        View snackbarView = tSnackbar.getView();
        snackbarView.setBackgroundColor(Color.RED);
        TextView textView = (TextView) snackbarView.findViewById(R.id.snackbar_text);
        textView.setTextColor(Color.WHITE);
        tSnackbar.show();
    }

    public static TSnackbar TSBErrorLongtimeShow(Activity activity, String msg){
        TSnackbar tSnackbar = TSnackbar.make(activity.getWindow().getDecorView(),msg,TSnackbar.LENGTH_INDEFINITE);
        tSnackbar.setActionTextColor(Color.BLACK);
        View snackbarView = tSnackbar.getView();
        snackbarView.setBackgroundColor(Color.RED);
        TextView textView = (TextView) snackbarView.findViewById(R.id.snackbar_text);
        textView.setTextColor(Color.WHITE);
        tSnackbar.show();
        return tSnackbar;
    }
}
